import {Injectable} from "@angular/core";

import {API} from "../../../constants/constants";
import {MsgResult} from "../../../models/msg-result";
import {Observable} from "rxjs";
import {RequestUtil} from "../../../util/request-util";

@Injectable()
export class EntInfosService {

  constructor(
    private requestUtil: RequestUtil
  ) { }

  //无参查询企业数据
  getEntInfos():Observable<MsgResult>{
     return this.requestUtil.get(API.getEntInfos);
  }

  //添加企业信息
  insertEntInfo(entInfo):Observable<MsgResult>{
    let params="name="+entInfo.name+"&entOrganCode="+entInfo.entOrganCode+"&regionCode="+entInfo.regionCode+"&phone="+entInfo.phone+
      "&onlineNum="+entInfo.onlineNum+"&isValid="+entInfo.isValid+"&isDisable="+entInfo.isDisable+"&remark="+entInfo.remark;
    return this.requestUtil.post(API.insertEntInfo,params);
  }

  //企业删除接口
  deleteEntInfo(id):Observable<MsgResult>{
    let params="id="+id;
    return this.requestUtil.get(API.deleteEntInfo,params);
  }

  //根据id查询
  getEntInfoById(id :string):Observable<MsgResult>{
    let params="id="+id;
    return this.requestUtil.get(API.getEntInfoById,params);
  }

  //企业修改接口
  updateEntInfo(entInfo):Observable<MsgResult>{
    let params="id="+entInfo.id+"&name="+entInfo.name+"&entOrganCode="+entInfo.entOrganCode+
      "&regionCode="+entInfo.regionCode+ "&phone="+entInfo.phone+"&onlineNum="+entInfo.onlineNum+"&isValid="+
      entInfo.isValid+ "&isDisable="+entInfo.isDisable+"&remark="+entInfo.remark;
    return this.requestUtil.post(API.updateEntInfo,params);
  }
  //获取行政区划树
  getRetrieveRegionsTree(): Observable<MsgResult> {
    return this.requestUtil.get(API.getRetrieveRegionsTree);
  }

}
